package com.security.system.controller;

import com.security.system.entity.SysUser;
import com.security.system.service.IndexService;
import com.security.utils.R;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Map;

@Controller
@RequestMapping("index")
public class IndexController {

    @Resource
    IndexService service;

    @GetMapping("")
    public String getIndexHtml(Authentication authentication,Map<Object,Object> map){
        SysUser principal = (SysUser) authentication.getPrincipal();
        map.put("username",principal.getUname());
        return "system/index/index";
    }

    @GetMapping("getMenu")
    @ResponseBody
    public R getMenu(Authentication authentication){
        return service.getMenu(authentication);
    }

}
